package ch.lom.clemens.android.bibliography.data;

import java.util.ArrayList;
import java.util.Collection;

public class MCollection {

	protected MendeleyConnector m_con;
	
	public String    id;
	public String name;
	public String type;
	public int    size;
	
	public static final int GENERIC  = 0;
	public static final int LIBRARY  = 1;
	public static final int AUTHORED = 2;
	public static final int GROUP    = 3; 
	

	protected int m_coltype = GENERIC; 
	
	public MCollection(MendeleyConnector con) {
		m_coltype = GENERIC;
		m_con = con;
	}
	
	public MCollection(MendeleyConnector con, int type) {
		m_coltype = type;
		m_con = con;
	}
	
	public Collection<MDocument> getDocuments() {
		
		Collection<MDocument> docs = new ArrayList<MDocument>();
		
		String [] docids =  m_con.getCollectionDocIDs(this);
		
		if (docids == null) return null;
		
		for (String id : docids) {
			docs.add(new MDocument(this, id));
		}
		
		return docs;
	}

	public void getDocument(MDocument doc) {
		m_con.fillDocument(doc);
	}
	
}
